home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / applets / collectn / htenumer.jav < prev    next >
Encoding:
Text File  |  1995-10-14  |  1.3 KB  |  56 lines

  1. /*
  2.   File: HTEnumeration.java
  3.  
  4.   Originally written by Doug Lea and released into the public domain. 
  5.   Thanks for the assistance and support of Sun Microsystems Labs, Agorics 
  6.   Inc, Loral, and everyone contributing, testing, and using this code.
  7.  
  8.   History:
  9.   Date     Who                What
  10.   24Sep95  dl@cs.oswego.edu   Create from collections.java  working file
  11.   13Oct95  dl                 Changed protection statuses
  12.  
  13. */
  14.   
  15. package collections;
  16.  
  17. import java.util.Enumeration;
  18. import java.util.NoSuchElementException;
  19.  
  20. /**
  21.  *
  22.  *
  23.  * Enumerator for collections based on hash tables
  24.  * @author Doug Lea
  25.  * @version 0.93
  26.  *
  27.  * <P> For an introduction to this package see <A HREF="index.html"> Overview </A>.
  28. **/
  29. final class HTEnumeration extends CEImpl {
  30.   private LLCell tab_[];
  31.   private LLCell cell_;
  32.   private int row_;
  33.  
  34.   public HTEnumeration(UpdatableCollection c, LLCell tab[]) { 
  35.     super(c);
  36.     tab_ = tab;
  37.     row_ = 0;
  38.     cell_ = null;
  39.   }
  40.  
  41. /**
  42.  * Implements java.util.Enumeration.nextElement.
  43.  * @see java.util.Enumeration#nextElement
  44. **/
  45.   public Object nextElement() { 
  46.     decRemaining();
  47.     // if this loop fails, then we've not detected a version change?
  48.     while (cell_ == null) cell_ = tab_[row_++];
  49.     Object v = cell_.element(); 
  50.     cell_ = cell_.next();
  51.     return v;
  52.   }
  53.             
  54. }
  55.  
  56.